import {exSQL} from "@/utils/SQLiteRequest.js"

export function createTablePwd(){
	var sqlTable = 'create table if not exists r_pwd("id" INT(10) NOT NULL UNIQUE,"name" CHAR,"gridCode" CHAR)' ;
	return exSQL(sqlTable);
}

/**
 * 创建用户表
 */
export function createTablePerson(){
	var sqlStr ="CREATE TABLE IF NOT EXISTS person ("
		+ "'id' VARCHAR(25)  NOT NULL PRIMARY KEY,"
		+ "'username' VARCHAR(25) NOT NULL UNIQUE,"
	    + "'tips' VARCHAR(25) NULL)"
	return exSQL(sqlStr);
}

/**
 * 创建主表
 */
export function createTableMain(){
	var sqlStr = "CREATE TABLE IF NOT EXISTS main_m("
	+ "'id' VARCHAR(25)  NOT NULL PRIMARY KEY,"
    + "'user_id' VARCHAR(25) NOT NULL,"
    + "'description' VARCHAR(50) NOT NULL,"
    + "'security_code' VARCHAR(100) NULL,"
    + "'website' VARCHAR(100) NULL,"
    + "'email' VARCHAR(50) NULL,"
    + "'registration' VARCHAR(50) NULL,"
    + "'usage' VARCHAR(50) NULL,"
    + "'remarks' VARCHAR(50),"
    + "'is_delete' INT,"
    + "'gmt_create' dateTime,"
    + "'gmt_modified' dateTime,"
    + "'gmt_delete' dateTime)"
	return exSQL(sqlStr)
}
/**
 * 创建安全问题表
 */
export function createTableQA(){
	var sqlStr =  "CREATE TABLE IF NOT EXISTS security_QA("
	+ "'id' VARCHAR(25) NOT NULL PRIMARY KEY,"
    + "'main_m_id' VARCHAR(25) NOT NULL,"
    + "' question' VARCHAR(100),"
    + "'answer' VARCHAR(100),"
    + "'is_delete' INT,"
    + "'gmt_create' dateTime,"
    + "'gmt_modified' dateTime,"
    + "'gmt_delete' dateTime)"
	return exSQL(sqlStr);
}

/**
 * 创建历史密码表
 */
export function createTableHistoryCode(){
	var sqlStr = "CREATE TABLE IF NOT EXISTS history_code("
	+ "'id' VARCHAR(25) NOT NULL PRIMARY KEY,"
	+ "'main_m_id' VARCHAR(25),"
	+ "'security_code' VARCHAR(100),"
	+ "'is_delete' INT,"
	+ "'gmt_create' dateTime,"
	+ "'gmt_modified' dateTime,"
	+ "'gmt_delete' dateTime)"
	return exSQL(sqlStr);
}

/**
 * 创建分类标签表
 */
export function createTableClassification(){
	var sqlStr = "CREATE TABLE IF NOT EXISTS classification("
	+ "'id' VARCHAR(25) NOT NULL PRIMARY KEY,"
    + "'user_id' VARCHAR(25) NOT NULL,"
    + "'label' VARCHAR(25),"
    + "'gmt_create' dateTime,"
    + "'gmt_modified' dateTime,"
    + "'gmt_delete' dateTime)"
	return exSQL(sqlStr)
}


/**
 * 创建标签——主表关联表
 */
export function createTableClassficationAndMain(){
	var sqlStr = "CREATE TABLE IF NOT EXISTS main_class("
	+ "'id' VARCHAR(25) NOT NULL PRIMARY KEY,"
	+ "'main_id' VARCHAR(25) NOT NULL,"
	+ "'classfication_id' VARCHAR(25) NOT NULL,"
	+ "'gmt_create' dateTime,"
	+ "'gmt_modified' dateTime,"
	+ "'gmt_delete' dateTime)";
	return exSQL(sqlStr);
}